<?php
namespace Kxdr\Model;
use Think\Model\ViewModel;
class EventGuessUserViewModel extends ViewModel {
	public $sid;
	public $eid;
	public $uid;
	public $wharr;
   public $viewFields = array(
	 'guess_user'=>array('_table'=>'sm_kxdr_user_guess','id'=>'guess_id','user_id','sid','eid','player_id','guess_type','guess_value','mixed_nick','guess_time','guess_value_difference','_type'=>'LEFT'),
	 'e_player'=>array('_table'=>'sm_kxdr_event_players','id'=>'epid','title','think_type','think_type_way','think_type_sign','target_data','event_id','player_id','player_descrip'=>'event_player_descrip','_on'=>'e_player.id=guess_user.epid','_type'=>'LEFT'),
	 'player'=>array('_table'=>'sm_kxdr_players','id','chinese_name'=>'player_name','description'=>'player_descrip','is_team','team_id','_on'=>'e_player.player_id=player.id','game_category','_type'=>'LEFT'),
     );
   public function getEventGuessUser(){
	    // unset($this->viewFields["player"]);
		$players = $this->where($this->wharr)->limit($this->lmtstr)->getField("guess_id,epid,player_name,event_player_descrip,title,think_type,think_type_way,guess_type,guess_value,guess_time,guess_value_difference,mixed_nick");
		foreach($players as $k=>$p){
			foreach(C("KXDR_THINK_WAY") as $way){
				if($p["think_type_way"]==$way["id"]){
					$players[$k]["think_type_way_name"]=$way["name"];break;
				}
			}
			if($p["guess_value_difference"]==0){
				$players[$k]["gvdmsg"] = "完全猜中";
			}elseif($p["guess_value_difference"]<0){
				$players[$k]["gvdmsg"] = "没猜中";
			}else{
				$players[$k]["gvdmsg"] = "差".$p["guess_value_difference"]."分猜中";
			}
			
		}
		return $players;
   }
   public function getTotal(){
	   return $this->where($this->wharr)->limit($this->lmtstr)->count();
   }
}